package table.tablemodel;

import java.util.List;

import javax.swing.table.AbstractTableModel;

import bank.Kunde;

public class KundenUebersichtTableModel extends AbstractTableModel {

	private static final long serialVersionUID = 100L;

    private static final String[] COLUMN_NAMES = {"Kundenname", "Kundennummer"};
	
	private List<Kunde> kunden;

	public KundenUebersichtTableModel() {
	    super();
	}

	@Override
	public int getColumnCount() {
		return COLUMN_NAMES.length;
	}

	@Override
	public int getRowCount() {
		return getKunden() == null ? 0 : getKunden().size();
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		Kunde kunde = getKunden().get(rowIndex);
		return kunde;
	}

	@Override
    public String getColumnName(int colNr) {
		return COLUMN_NAMES[colNr];
	}

	public List<Kunde> getKunden() {
		return kunden;
	}

	public void setKunden(List<Kunde> aKunden) {
		kunden = aKunden;
		fireTableDataChanged();
	}
}
